package cate.game.play.skill.passive.hero;

import cate.game.play.config.PlayCfgArgs;
import cate.game.play.proce.action.ctx.SkillActionCtx;
import cate.game.play.skill.passive.PassiveHandler;

/**
 * 单次承受伤害超过20%将会获得攻击100%的护盾，并获得1层【聚气】
 */
public class 寸劲PH extends PassiveHandler {

	private double 血量;

	private int 护盾buff;

	private int 聚气buff;

	private int 聚气数量;

	//血量=2000&护盾buff=？？&聚气buff=？？&聚气数量=1
	@Override
	public void parse(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		血量 = args.getWDouble("血量", 0d);
		护盾buff = args.getInt("护盾buff", 0);
		聚气buff = args.getInt("聚气buff", 0);
		聚气数量 = args.getInt("聚气数量", 0);
	}

	@Override
	public void parseExt(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		聚气数量 += args.getInt("聚气数量", 0);
	}

	@Override
	public void afterSufferOneAttack(SkillActionCtx action, long totalDamage, boolean strike) {
		if (skill.owner.isDead()) {
			return;
		}
		if (totalDamage / skill.owner.attr.total().hpTotal() < 血量) {
			return;
		}
		skill.owner.buff.tryAddByTid(action, 护盾buff);
		skill.owner.buff.tryAddSome(action, 聚气buff, 聚气数量);
	}
}
